home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
vgl20
/
vglmouse.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-14
|
3KB
|
120 lines
/*****************************************************************************
VGLMOUSE.C
Simple routines for mouse handling. Nothing special, but somebody asked
for them. Should work with all Microsoft compatible mice.
Mark
morley@camosun.bc.ca
*****************************************************************************/
#include <dos.h>
static int Mouse = 0; /* Whether or not we have a mouse */
static int Hidden = 0; /* Whether or not it's hidden */
/*****************************************************************************
Returns 1 if there is a mouse attached, 0 if not. You must have first
called vglMouseInit()
*****************************************************************************/
int vglMousePresent()
{
return Mouse;
}
/*****************************************************************************
Initialize the mouse (if it exists). Returns 1 if the mouse exists, 0 if
it doesn't. By default the mouse is hidden and must be explicitly turned
on (vglShowMouse)
*****************************************************************************/
int vglInitMouse()
{
union REGS r;
r.x.ax = 0;
int86( 0x33, &r, &r );
if( r.x.ax )
{
Mouse = 1;
r.x.ax = 0x1c;
r.x.bx = 1;
int86( 0x33, &r, &r );
}
else
Mouse = 0;
Hidden = 1;
return Mouse;
}
/*****************************************************************************
Turns on the mouse cursor.
*****************************************************************************/
int vglShowMouse()
{
union REGS r;
if( Mouse && Hidden )
{
r.x.ax = 1;
int86( 0x33, &r, &r );
Hidden = 0;
return 1;
}
return 0;
}
/*****************************************************************************
Hides the mouse cursor.
*****************************************************************************/
int vglHideMouse()
{
union REGS r;
if( Mouse && !Hidden )
{
r.x.ax = 2;
int86( 0x33, &r, &r );
Hidden = 1;
return 1;
}
return 0;
}
/*****************************************************************************
Hides the mouse cursor if it lies within the specified rectangle.
*****************************************************************************/
int vglHideMouseIf( int x1, int y1, int x2, int y2 )
{
int x, y, b;
if( Mouse && !Hidden )
{
vglGetMouseInfo( &x, &y, &b );
if( x >= x1 && x <= x2 && y >= y1 && y <= y2 )
return( vglHideMouse() );
}
return 0;
}
/*****************************************************************************
Returns the mouse status. It's X and Y position is returned in 'x' and 'y',
and its button status is returned in 'b'.
*****************************************************************************/
int vglGetMouseInfo( int* x, int* y, int* b )
{
union REGS r;
if( Mouse )
{
r.x.ax = 3;
int86( 0x33, &r, &r );
*b = r.x.bx;
*x = r.x.cx;
*y = r.x.dx;
return *b;
}
else
return 0;
}